package cn.edu.fzu.homemaking.controller;

import cn.edu.fzu.homemaking.api.SysApi;
import cn.edu.fzu.homemaking.domain.enums.CompanyStatusEnum;
import cn.edu.fzu.homemaking.domain.enums.LabelStatusEnum;
import cn.edu.fzu.homemaking.web.Result;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author jiebin
 * @Date 2023/4/7
 */
@RestController
@RequestMapping("/api/user")
@Api(tags = "公司管理")
public class SysController {

    @Resource
    private SysApi sysApi;

    @GetMapping("company/list")
    @ApiOperation(value = "获取公司列表", httpMethod = "GET")
    @ApiResponse(code = 200, message = "", response = Result.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "provinceId", readOnly = false, value = "省id"),
            @ApiImplicitParam(name = "cityId", readOnly = false, value = "市id"),
            @ApiImplicitParam(name = "areaId", readOnly = false, value = "地区id"),
            @ApiImplicitParam(name = "name", required = false, value = "公司名字"),
            @ApiImplicitParam(name = "labelId", value = "服务标签id"),
            @ApiImplicitParam(name = "pageNum", required = true, value = "页码"),
            @ApiImplicitParam(name = "pageSize", required = true, value = "页面大小")})
    public Result listCompany(Long provinceId, Long cityId, Long areaId, String name, Long labelId,
                              Integer pageNum, Integer pageSize){
        Result result =  sysApi.companyList(provinceId,areaId,cityId,null,null,null,
                null, name,null,labelId, CompanyStatusEnum.NORMAL,pageNum,pageSize);
        return result;
    }

    @GetMapping("label/list")
    @ApiOperation(value = "获取标签列表", httpMethod = "GET")
    @ApiImplicitParam(name = "status", value = "标签状态", required = false)
    @ApiResponse(code = 200, message = "", response = Result.class)
    public Result listLabels(LabelStatusEnum status){
        Result result = sysApi.listLabels(null, status, null, null);
        return result;
    }

}
